<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

//设置密码混淆
function psMD5($password){
	$password = $password.'dbkjlgy';
	return md5($password);
}

// 定义一个函数获取客户端IP地址
function getIP(){
	global $ip;
	if (getenv("HTTP_CLIENT_IP")){
		$ip = getenv("HTTP_CLIENT_IP");
	}else if(getenv("HTTP_X_FORWARDED_FOR")){
		$ip = getenv("HTTP_X_FORWARDED_FOR");
	}else if(getenv("REMOTE_ADDR")){
		$ip = getenv("REMOTE_ADDR");
	}else{
		$ip = "Unknow IP";
	}
	return $ip;
}

//返回结果
function adminRes($code,$msg,$url=''){
	$res = [
		'code'=>$code,
		'msg'=>$msg,
		'url'=>$url
	];
	return json_encode($res);
}